import json
from datetime import datetime

from mqtt.method.remote_control_method import RemoteControlMethodEnum
from mqtt.callback.callback_manager import callbackManager
"""
    设备 > 云平台 (DRC 上行)处理方法  /drc/up
"""
class DrcUpCallbackHandler(callbackManager):
    def handle(self, payload):
        data = json.loads(payload)
        method = data['method']

        now = datetime.now()
        log_time = now.strftime('%Y%m%d %H%M%S')
        if RemoteControlMethodEnum.DRONE_CAMERA_OSD_INFO_PUSH.get_method() == method :
            # 摄像头osd推送信息
            print("osd推送信息")
        elif RemoteControlMethodEnum.CAMERA_AIM.get_method() == method :
            self.publish_callback_message(f"{log_time}_双击成为aim响应:{payload}")
        elif RemoteControlMethodEnum.CAMERA_LOOK_AT.get_method() == method :
            self.publish_callback_message(f"{log_time}_负载控制—Look At响应:{payload}")
        elif RemoteControlMethodEnum.CAMERA_PHOTO_TAKE.get_method() == method :
            self.publish_callback_message(f"{log_time}_开始拍照信息响应:{payload}")
        elif RemoteControlMethodEnum.CAMERA_PHOTO_STOP.get_method() == method :
            self.publish_callback_message(f"{log_time}_停止拍照信息响应:{payload}")
        elif RemoteControlMethodEnum.CAMERA_STATE_PUSH.get_method() == method :
            print("相机状态上报")
        elif RemoteControlMethodEnum.CAMERA_PHOTO_INFO_PUSH.get_method() == method :
            print("拍照信息上报")
        elif RemoteControlMethodEnum.DRONE_STATE_PUSH.get_method() == method:
            print("飞行器状态信息上报")
        print(data['data'])

